'''
Created on 31/07/2011

@author: Digao
'''
def toInt(arg):
    return int(arg)

def toStr(a,b):
    return str(a)+' '+str(b)

input = open('input.in')
CASES = int(input.readline())
for case in range(1,CASES+1):
    N,K,B,T = map(toInt,input.readline().strip().split())
    X = map(toInt,input.readline().strip().split())
    V = map(toInt,input.readline().strip().split())
    
    times = [float(B-X[i])/V[i] for i in xrange(N)]
    slow_ones=0
    ok_ones=0
    swaps=0
    for i in xrange(-1,-N-1,-1):
        if times[i]>T:
            slow_ones+=1
        elif ok_ones<K:
            swaps+=slow_ones
            ok_ones+=1
        else:
            break       
            
        
    
    print 'Case #%d: %s'%(case,ok_ones==K and str(swaps) or 'IMPOSSIBLE')
    


